<template>
  <div class="audit-save">
    <el-form ref="auditForm" label-position="top" :model="ruleForm" :rules="rules">
      <el-form-item label="处理意见" prop="remark">
        <el-input v-model="ruleForm.remark" type="textarea" :rows="5" />
      </el-form-item>
      <el-form-item label="附件上传" prop="file">
        <DragUpload ref="dragRef" />
      </el-form-item>
    </el-form>
    <div class="f-r a-c" style="margin: 10px 0;">
      <el-button type="primary" @click="handleSubmit(true)">审核通过</el-button>
      <el-button @click="handleSubmit(false)">审核驳回</el-button>
    </div>
  </div>
</template>

<script>
import DragUpload from '@/components/DragUpload'
export default {
  name: 'AuditSave',
  components: { DragUpload },
  data() {
    return {
      files: [],
      fileList: [],
      rules: {
        remark: [{ required: true, message: '输入不能为空' }]
      },
      ruleForm: {
        remark: ''
      }
    }
  },
  methods: {
    handleSubmit(status) {
      this.$refs.auditForm.validate(async(valid) => {
        if (valid) {
          const files = this.$refs.dragRef.getFiles()
          console.log(files)
          if (files) {
            // status true 通过 驳回
            this.$emit('save', {
              status,
              remark: this.ruleForm.remark,
              files
            })
          }
        }
      })
    }
  }
}
</script>

<style scoped>

</style>
